package cn.huaguodong.hgd001.controller;

import com.jfinal.core.Controller;
import com.jfinal.kit.Base64Kit;

import cn.huaguodong.hgd001.model.User;

public class LoginController extends Controller {
	private User user = new User();
	public void index() {
		this.render("login.html");
	}
	
	public void login() {
	user = user.findFirst("select * from `user` where ( `user` = '"
	+ this.getPara("useroremail") + "' or `email` = '" + this.getPara("useroremail") 
	+ "' ) and `password` ='" + Base64Kit.encode(this.getPara("password")) + "'");
	if(user != null) {
		this.setSessionAttr("usersession", user);
		this.redirect("/admin");
	}else {
		this.redirect("/admin/login");
	}
		
	}
}
